package com.lizongbo.seotijian.rules.beans;

import java.io.BufferedReader;
import java.io.StringReader;

public class WhoisInfo {
	private String domainName = "";
	private String status = "";
	private String registrar = "";
	private String whoisServer = "";
	private String creationDate = "";
	private String expirationDate = "";
	private String updatedDate = "";

	public WhoisInfo() {
		super();
	}

	public WhoisInfo(String domainName, String status, String registrar,
			String whoisServer, String creationDate, String expirationDate,
			String updatedDate) {
		super();
		this.domainName = domainName;
		this.status = status;
		this.registrar = registrar;
		this.whoisServer = whoisServer;
		this.creationDate = creationDate;
		this.expirationDate = expirationDate;
		this.updatedDate = updatedDate;
	}

	public String getDomainName() {
		return domainName;
	}

	public void setDomainName(String domainName) {
		this.domainName = domainName;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getRegistrar() {
		return registrar;
	}

	public void setRegistrar(String registrar) {
		this.registrar = registrar;
	}

	public String getWhoisServer() {
		return whoisServer;
	}

	public void setWhoisServer(String whoisServer) {
		this.whoisServer = whoisServer;
	}

	public String getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(String creationDate) {
		this.creationDate = creationDate;
	}

	public String getExpirationDate() {
		return expirationDate;
	}

	public void setExpirationDate(String expirationDate) {
		this.expirationDate = expirationDate;
	}

	public String getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(String updatedDate) {
		this.updatedDate = updatedDate;
	}

	public void fromWhoisInfo(String whois) {
		try {
			BufferedReader in = new BufferedReader(new StringReader(whois));
			String line;
			while ((line = in.readLine()) != null) {
				line = line.trim();
				if (line.contains("whois:")) {
					whoisServer = line.substring("whois:".length()).trim();
				}
			}

		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	@Override
	public String toString() {
		return "WhoisInfo [creationDate=" + creationDate + ", domainName="
				+ domainName + ", expirationDate=" + expirationDate
				+ ", registrar=" + registrar + ", status=" + status
				+ ", updatedDate=" + updatedDate + ", whoisServer="
				+ whoisServer + "]";
	}

}
